<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <input type="button" onclick="myalert()">
    <input type="button" id="button1">
    <script type="text/javascript">
        //提取行间事件(匿名函数)
        window.onload = function () {
            var btn = document.getElementById("button1");
            btn.onclick = myalert;
            function myalert(){
                alert("button1")
            }
        }


        //行间事件函数调用
        function myalert(){
            alert("ok");
        }

        //执行过程
        fun();
        alert(aa)
        function fun() {
            alert("hello javascript");
        }
        //函数执行
        var aa=22;
    </script>
</body>
</html>